//
//  HMTabBarController.swift
//  SinaWeiBo
//
//  Created by gaojie on 16/9/22.
//  Copyright © 2016年 iteam. All rights reserved.
//

import UIKit

class HMTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
//添加子控制器
     addChildViewControllers()
        
    
    
    }
    //MARK: 添加控制器
    func addChildViewControllers() {
        addChildViewController(vc: HMHomeTableViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(vc: HMMessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(vc: HMDiscoverTableViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(vc: HMProfileTableViewController(), title: "我", imageName: "tabbar_profile")
    }

    func addChildViewController(vc: UIViewController,title: String,imageName: String) {
        //设置title
        //home.title = "首页"
        vc.navigationItem.title = title
        //要同时设置title 和图片才可以显示
        vc.tabBarItem.title = title
        vc.tabBarItem.image = UIImage(named: imageName)
        //设置选中图片
        vc.tabBarItem.selectedImage = UIImage(named: imageName + "_selected")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
        //设置文字的颜色
        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orange], for: .selected)
        //vc.tabBarItem.imageInsets = UIEdgeInsets(top: 5, left: 0, bottom: -5, right: 0)
        //设置字体
        vc.tabBarItem.setTitleTextAttributes([NSFontAttributeName : UIFont.systemFont(ofSize: 11)], for: .normal)
        //修改徽标的颜色
        vc.tabBarItem.badgeColor = UIColor.purple
        //不显示
        vc.tabBarItem.badgeValue = nil
        let nav = UINavigationController(rootViewController: vc)
        addChildViewController(nav)
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

}
